<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 吕旺平
  Date: 2020/1/1
  Time: 18:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html>
<head>
	<title>Title</title>
	<jsp:include page="/layout/_import.jsp"></jsp:include>
</head>
<body>
<jsp:include page="/layout/_nav.jsp"></jsp:include>

<div class="container">
	<main role="main" class="pb-3">

		<form novalidate="novalidate">
			<div class="form-group row">
				<div class="col-sm-10 offset-sm-2">
					<img src="${pet.photo}" alt="图片加载失败"
						 style="height: 300px; width: 300px;">
				</div>
			</div>
			<div class="form-group row">
				<label class="col-sm-2 col-form-label" for="name">宠物名</label>
				<div class="col-sm-10">
					<input readonly class="form-control-plaintext" type="text" id="name" name="name"
						   value="${pet.name}">
				</div>
			</div>
			<div class="form-group row">
				<label class="col-sm-2 col-form-label" for="birth">生日</label>
				<div class="col-sm-10">
					<input readonly class="form-control-plaintext valid" type="date" id="birth" name="birth"
						   value="${pet.birthdate}" aria-invalid="false">
				</div>
			</div>


			<div class="form-group row">
				<div class="col-sm-12">
					<c:choose>
						<c:when test="${user!=null && user.role=='admin'}">
							<a class="btn btn-secondary" href="/petmanage">返回列表</a>
						</c:when>
						<c:otherwise>
							<a class="btn btn-secondary" href="/petmanage?m=my">返回列表</a>
						</c:otherwise>
					</c:choose>
                    <c:if test="${user!=null && user.role=='admin'}">
						<a href="/petmanage?m=edit&id=${pet.id}&detail" class="btn btn-primary">编辑</a>
                        <a href="Visit?m=toAdd&petId=${pet.id}" class="btn btn-primary">添加</a>
                    </c:if>
				</div>
			</div>

			<table class="table" style="text-align: center">

				<thead class="thead-dark">
				<tr>
					<th scope="col">id</th>
					<th scope="col">诊断时间</th>
					<th scope="col">病情描述</th>
					<th scope="col">治疗方案</th>
					<c:if test="${user!=null && user.role=='admin'}">
						<th scope="col">操作</th>
					</c:if>
				</tr>
				</thead>
				<tbody>
				<c:forEach items="${vists}" var="v">
					<tr>
						<th scope="row">${v.id}</th>
						<td>${v.visitdate}</td>
						<td>${v.description}</td>
						<td>${v.treatment}</td>
						<c:if test="${user!=null && user.role=='admin'}">
							<td>
							<a href="/Visit?m=del&petid=${pet.id}&id=${v.id}" type="submit" class="btn btn-danger"
									onclick="return confirm('确认删除？')">删除
							</a></td>
						</c:if>

					</tr>
				</c:forEach>

				</tbody>
			</table>
		</form>
	</main>
</div>
</body>
</html>
